#define _CRT_SECURE_NO_WARNINGS 1		
#include"stack.h"
void stackinit(stack* ps)
{
	ps->array = (STDtype*)malloc(sizeof(STDtype) * 4);
	ps->capacity = 4;
	ps->top = 0;
}
void stackdestroy(stack* ps)
{

}
void stackpush(stack* ps, STDtype x)
{
	assert(ps);
	if (ps->top == ps->capacity)
	{
		STDtype* tmp = (STDtype*)realloc(ps->array, ps->capacity * 2 * (sizeof(STDtype)));
		if (tmp == NULL)
		{
			printf("realloc failed\n");
			exit(-1);
		}
		else
		{
			ps->array = tmp;
			ps->capacity *= 2;
		}
	}
	ps->array[ps->top] = x;
	ps->top++;
}
void stackpop(stack* ps) 
{
	assert(ps);
	ps->top--;
}
char yunsuanfubijiao(char a, char b)
{
	if (b == '+' || b == '-')
	{
		if (a == '(' || a == '#')
			return '<';
		else
			return '>';
	}
	else if (b == '*' || b == '/')
	{
		if (a == '*' || a == '/' || a == ')')
			return '>';
		else
			return '<';
	}
	else if (b == '(')
	{
		return '<';
	}
	else if (b == ')')
	{
		if (a != '(')
			return '>';
		else
			return '=';
	}
}
int yunsuan(int num1, int num2, char yunsuanfuhao)
{
	if (yunsuanfuhao == '+')
	{
		return num1 + num2;
	}
	else if (yunsuanfuhao == '-')
	{
		return num1 - num2;
	}
	else if (yunsuanfuhao == '*')
	{
		return num1 * num2;
	}
	else if (yunsuanfuhao == '/')
	{
		return num1 / num2;
	}
}